package controllers

import (
	"databaseStudy/models"
	"databaseStudy/models/globalValues"
	beego "github.com/beego/beego/v2/server/web"
)

type GetEmpInfoController struct {
	beego.Controller
}
type GetDepInfoController struct {
	beego.Controller
}
type GetTransInfoController struct {
	beego.Controller
}

func (c GetEmpInfoController) Post() {
	var token = c.GetString("token")
	if !globalValues.CheckToken(token) {
			c.Ctx.ResponseWriter.WriteHeader(403)
			return
	}
	var res, err = models.GetAllEmployeeInformation()
	if err != nil {
		c.Ctx.ResponseWriter.WriteHeader(500)
		return
	}
	c.Data["json"] = res
	_ = c.ServeJSON()
}
func (c GetDepInfoController) Post() {
	var token = c.GetString("token")
	if !globalValues.CheckToken(token) {
		c.Ctx.ResponseWriter.WriteHeader(403)
		return
	}
	var res, err = models.GetAllDepInformation()
	if err != nil {
		c.Ctx.ResponseWriter.WriteHeader(500)
		return
	}
	c.Data["json"] = res
	_ = c.ServeJSON()
}
func (c GetTransInfoController) Post() {
	var token = c.GetString("token")
	if !globalValues.CheckToken(token) {
		c.Ctx.ResponseWriter.WriteHeader(403)
		return
	}
	var res, err = models.GetAllTransInformation()
	if err != nil {
		c.Ctx.ResponseWriter.WriteHeader(500)
		return
	}
	c.Data["json"] = res
	_ = c.ServeJSON()
}
